export default {
	//获取多少分钟前的数据
	get_db_data:(state)=>(_data)=> {
			// let _before_time = _data.before_time * 60 * 1000
			// let time = new Date().getTime() - _before_time
			let where = ` where antenna in (${_data.antenna})`
			return new Promise((resolve, reject)=>{
				plus.sqlite.selectSql({
					name: 'zng_data',
					sql: `select count(barcode) as count_num,*  from rfid_data ${where} group by barcode order by time desc;`,
					success: function(data) {
						// console.log(data);
						resolve(data)
					},
					fail: function(e) {
						console.log('selectSql failed: ' + JSON.stringify(e));
						reject([])
					}
				})
			})
	},
	getvideo_db_data:(state)=>(_data)=> {
		return new Promise((resolve, reject)=>{
			plus.sqlite.selectSql({
				name: 'zng_data',
				// sql: `select * from video_data order by id limit ${_data.pageSize} offset ${_data.page};`,
				sql: `select * from video_data order by time desc limit ${_data.pageSize} offset ${_data.page};`,
				success: function(data) {
					console.log(data);
					resolve(data)
				},
				fail: function(e) {
					console.log('selectSql failed: ' + JSON.stringify(e));
					reject([])
				}//select * from info where time>='2016-01-10 12:00:00' and time<='2016-04-30 12:00:00'
			})
		})
	},
	getvid_db_data:(state)=>(_data)=> {
		return new Promise((resolve, reject)=>{
			plus.sqlite.selectSql({
				name: 'zng_data',	
				// sql: `select * from video_data where time between ${_data.tobDate} and ${_data.afterDate}`,
				// sql: `select * from video_data where time BETWEEN time like(${_data.tobDate}) AND time like(${_data.afterDate})`,
				
				sql: `select * from video_data where time > '${_data.tobDate}' and time< '${_data.afterDate}'`,
				// sql: `select * from video_data where time>=2021-05-06 09:33:00 and time<=2021-05-06 09:37:00`,
				success: function(data) {
					console.log(data);
					resolve(data)
				},
				fail: function(e) {
					console.log('selectSql failed: ' + JSON.stringify(e));
					reject([])
				}
			})
		})
	},
	delvid_db_data:(state)=>(_data)=> {
		return new Promise((resolve, reject)=>{
			plus.sqlite.selectSql({
				name: 'zng_data',	
				// sql: `select * from video_data where time between ${_data.tobDate} and ${_data.afterDate}`,
				// sql: `select * from video_data where time BETWEEN time like(${_data.tobDate}) AND time like(${_data.afterDate})`,
				// DELETE FROM sessions WHERE timestamp >= '2010-12-06' AND timestamp < '2010-12-07'
				sql: `delete from video_data where time <= '${_data.tobDate}'`,
				// sql: `select * from video_data where time>=2021-05-06 09:33:00 and time<=2021-05-06 09:37:00`,
				success: function(data) {
					console.log(data);
					resolve(data)
				},
				fail: function(e) {
					console.log('selectSql failed: ' + JSON.stringify(e));
					reject([])
				}
			})
		})
	},
}